$(function(){
    var bindCardFail = null;
	layui.use(['layer'],function(){
		layer = layui.layer;
		//input属性
		$('input').placeholder();
		//
		$(".add-card-close").on('click',function(){
			parent.eventBankPanelClose();
		})
		
	})
	$("#btn-submit").on('click',function(){
			// layer.msg('银行卡添加成功！',
			// 	{
			// 		icon: 1,
			// 		skin:'bank-layer-skin',
			// 		 area: ['380px', '70px'],
			// 	},
			// 	function(){
			// 	parent.eventBankPanelClose();
			// });

			/*绑定银行卡失败*/
        bindCardFail = layer.open({
            type: 1,
            title: false,
            shadeClose: false,
            closeBtn: 0,
            skin: 'bank-layer-skin',
            area: ['600px', '412px'],
            content: '<div id="alertFail">\
    					<div class="add-card-head">\
							<div class="title"><i></i>绑定银行卡</div>\
							<div class="bind-card-close"></div>\
						</div>\
						<i class="bank-card-icon"></i>\
                        <h1>绑卡失败，换张卡试试</h1>\
                        <div class="fail">\
                            <h2>成功绑卡小贴士</h2>\
                            <p>1、绑定银行卡时只能绑定借记卡，不能绑定贷记卡（透支卡），每个账户最多支持 绑定10张银行卡</a></p>\
                            <p>2、绑定银行卡时填写的手机号需和当时在银行办理银行卡时的预留手机号码一致。 预留手机号可以去办卡行重新设置哦</p>\
                            <p>3、若未开通无卡支付功能，则需要到银行开通无卡支付功能，同时需要对无卡支 付额度进行设置。</p>\
                        </div>\
                   </div>'
        });
    });

    $("#btn-cancel").on('click',function(){
				parent.eventBankPanelClose();
    });

    /*关闭绑定银行卡失败*/
    $('.bind-card-close').on("click",function(){

    });
	//SELECT -> INPUT
	$("#sub_bank_select").on("click",function(){
        eventSubBankToggle(SUB_BANK_STATE.SELECT_TO_INPUT);
	})
	//INPUT -> SELECT
    $("#sub_bank_input").on("click",function(){
        eventSubBankToggle(SUB_BANK_STATE.INPUT_TO_SELECT);
    })

});

/*切换绑定银行卡的方法*/

var SUB_BANK_STATE = {
    'SELECT_TO_INPUT':'1',
    'INPUT_TO_SELECT':'2'
}
var eventSubBankToggle = function(state) {
    var subBankSelectDom = $("#sub_bank_select").parent();
    var subBankInputDom = $("#sub_bank_input").parent();

    if(state && state === SUB_BANK_STATE.SELECT_TO_INPUT) {
        subBankSelectDom.hide();
        subBankInputDom.show();
    }
    if(state && state === SUB_BANK_STATE.INPUT_TO_SELECT) {
        subBankSelectDom.show();
        subBankInputDom.hide();
    }
}